package com.hg.miaosha.product;

import cn.hutool.json.JSONUtil;
import com.hg.miaosha.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: skh
 * @Date: 2019/10/16 15:19
 * @Description:
 */
@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/insert")
    public R insertProduct() {
        productService.insertProduct();
        return R.success("success");
    }

    @GetMapping("/info/{productId}")
    public String getProductById(@PathVariable Integer productId) {
        ProductDO productByProductId = productService.getProductByProductId(productId);
        return JSONUtil.toJsonStr(productByProductId);
    }
}
